package com.zhangjun;


import com.zhangjun.Dao.StudentDao;
import com.zhangjun.entity.Student;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author 张钧
 * @Description
 */
public class Main {

    StudentDao studentDao;

    @Before
    public void before(){
        // 1.加载spring配置文件
        ApplicationContext context = new ClassPathXmlApplicationContext("ApplicationContext.xml");
        // 2.获取配置创建的对象
        studentDao = (StudentDao) context.getBean("studentDao");
    }

    @Test
    public void createTable(){
        studentDao.createTable();
    }

    @Test
    public void insert(){
        studentDao.insert(new Student().setName("测试2").setScore(70));
    }

    @Test
    public void query(){
        System.out.println(studentDao.query());
    }

    @Test
    public void update(){
        studentDao.update(new Student().setId(1).setName("测试1").setScore(70));
    }

    @Test
    public void delete(){
        studentDao.delete(1);
    }

    @Test
    public void drop(){
        studentDao.drop();
    }

    @Test
    public void transfer(){
        studentDao.transfer(1,2,30);
    }
}